< previous page page_146 next page >

Page 146
Adding CheckSize Options to the VText Control
Another important form-level validation option is to check the length of the input string. You need three new properties: CheckSize (Boolean), MinLength (integer), and MaxLength (integer). The code in Listing 5.30 shows the modifications to the general declaration section of the UserControl.
Type.gifListing 5.30. Modifying the declaration section of VText.
' ------------------------------------------------
' CheckSize values
'
' event list
Public Event CheckSizeError(vValue)
' Properties
Dim m_CheckSize As Boolean
Dim m_MinLength As Integer
Dim m_MaxLength As Integer
' Default values
Const m_def_CheckSize = 0
Const m_def_MinLength = 0
Const m_def_MaxLength = 0
Next, update the InitProperties event to set the default values for these new properties. See Listing 5.31 for code to add to the InitProperties event.
Type.gifListing 5.31. Modifying the InitProperties event.
'
    ' CheckSize properties
    m_CheckSize = m_def_CheckSize
    m_MinLength = m_def_MinLength
    m_MaxLength = m_def_MaxLength
Now, you need to modify the ReadProperties and WriteProperties events for the VText control. Listing 5.32 shows you how to modify the ReadProperties event.
Type.gifListing 5.32. Modifying the ReadProperties event.
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    '
    ' read design-time property values
    '

 
< previous page page_146 next page >

If you like this book, buy it!